1. Field of the Invention
The invention relates to video processing, and more particularly to motion prediction and encoding of video data.
2. Description of the Related Art
The new upcoming H.264 compression standard can provide good video quality at substantially lower bit rates than previous standards by adopting features such as sub-pixel accuracy and multiple-referencing. The video compression process can be generally divided into 5 parts which include: inter-prediction/intra-prediction, transform/inverse-transform, quantization/inverse-quantization, loop filter, and entropy encoding. H.264 is used in various applications such as Blu-ray Discs, DVB broadcasting services, direct-broadcast satellite television services, cable television services, and real-time videoconferencing.
A video datastream comprises a plurality of frames, and each frame is divided into a plurality of coding units (e.g. macroblocks or extended macroblocks) to be respectively processed by a video encoder. Each coding unit can be segmented into quad-tree partitions, and a leaf coding unit is called a prediction unit. A prediction unit can be further segmented into quad-tree partitions, and each partition is assigned with a motion parameter. In order to reduce the cost of transmitting enormous amount of motion parameters, a motion vector predictor (MVP) is calculated for each partition by referencing to adjacent coded blocks, coding efficiency can thus be improved as the motion of the adjacent blocks tends to have high spatial correlation. Referring to FIG. 1, a schematic diagram illustrates adjacent blocks of a current unit 112. A current frame 102 comprises a current unit 112 and a plurality of candidate units A, B, C, and D neighboring to the current unit 112. The candidate unit A is on a left side of the current unit 112, the candidate unit B is on an upper side of the current unit 112, the candidate unit C is in line with an upper-right direction of the current unit 112, and the candidate unit A is in line with an upper-left direction of the current unit 112. Generally, an MVP of a current unit 112 is determined by comparing the motion vectors of the candidate units A, B, and C, and selecting a medium motion vector to be the MVP of the current unit 112. When the candidate unit C does not exist, the motion vectors of the candidate units A, B, and D are compared to each other to select a medium motion vector, and the medium motion vector is determined to be the MVP of the current unit 112.
With slight amendment to the above motion vector prediction method, motion vector competition (MVC) is also provided for motion prediction. According to MVC, more motion vectors are included in a candidate set for motion prediction of a current unit to improved accuracy of motion prediction. For example, the candidate set may comprise motion vectors of adjacent blocks of the current unit 112, as well as a motion vector of a collocated unit 114 which has the same location in a reference frame 104 as that of the current unit 112 in the current frame 102. Rate-distortion optimization (RDO) is used to select a final motion vector predictor for the current unit from the candidate set. The motion vector of the current unit is predicted according to the final motion vector predictor. An index of the final motion vector predictor selected from the candidate set is sent as prediction information to signal video decoders which motion vector predictor is chosen for the current unit.
Referring to FIG. 2, a flowchart of a motion prediction method 200 is shown. First, motion vectors of a plurality of candidate units corresponding to a current unit are obtained to include in a candidate set (step 202). The motion vectors in the candidate set are then compared to each other. When the motion vectors are not equal to each other (step 204), a motion vector predictor is selected from the candidate set (step 206), and a motion vector of the current unit is predicted according to motion vector predictor (step 208). Finally, prediction information about the selected motion vector predictor is generated and then sent in the bitstream (step 210). When the motion vectors in the candidate set are equal to each other (step 204), a motion vector of the current unit is predicted according to any of the motion vectors in the candidate set (step 212), and no prediction information about the motion vector predictor is generated and sent in the bitstream.
A parsing error in decoding the bitstream may occur due to incorrect decoding. When a parsing error occurred in syntax parsing during video decoding, all consequent video processing will be failed until a next synchronization symbol is detected. The parsing error may be propagated if inter-frame entropy coding is allowed, an example of inter-frame entropy coding is using motion vectors of previous frame as a motion vector predictor of a current frame to achieve coding gain improvement. Synchronization symbols such as the frame start code used to re-initialize frames may not stop the parsing error propagation. The above mentioned motion vector competition method may also induce parsing error propagation. According to the motion vector competition method 200 of FIG. 2, when the motion vectors in the candidate set are equal to each other, prediction information signaling the motion vector predictor is not sent in the bitstream. When the prediction information about the motion vector predictor is omitted, the data amount of the coded video bitstream sent to the video decoder is reduced. If the video decoder fails to detect intended omission of the prediction information and mistakes a subsequent segment of the coded video datastream as the prediction information, subsequent data in the coded video datastream will be erroneously decoded and this parsing error would propagate.
A parsing error in decoding of a prior frame may lead to a parsing error in decoding of a plurality of succeeding frames, is referred to as parsing error propagation. When a first succeeding frame takes the prior frame as a reference frame, encoding of the first succeeding frame uses coded information of the prior frame. If a parsing error occurs in decoding of the prior frame, because decoding of the first succeeding frame requires decoded information of the prior frame, the parsing error propagates to decoding of the first succeeding frame. When a second succeeding frame takes the first succeeding frame as a reference frame, the parsing error also propagates to decoding of the second succeeding frame. Thus, parsing error propagation will seriously impact decoding of a video datastream.